$(function(){
	//触摸触发事件
	
	var screenWidth = $(window).width();
	var gameArea;
	var lifeInfo;
	var current_page=1;
	var timer_enter=new Date().getTime();
	var music_on=true;
	var success_count = 0; 	//成功成功次数
	var error_count = 0;
	var game_level = 0;	//统计关卡数
	var game_level_all = 30;//总关卡
	var five_succ_count = 0;//成功五个的次数
	var correctArr = []; //统计总共翻转是否正确
	var trueArr = []; //翻转正确数组
	var falseArr = []; //翻转错误数组
	var audio_gold = document.createElement("audio");
	audio_gold.src =ROOT+"mp3/gold.mp3";
	var lastTrueLevel = 0;	//最后一次正确的关卡
	var flip_out_time = 1500;//设置自动翻开正确penguin的时间
	var fn_timer = null;	
	var auto_next_time = 15000//若无操作，自动进入下一级
	
	var post_currect = 0;
	var post_false = 0;
	
	var start_respond_time = 0;
	var respond_time = 0;
	var respond_times = [];
	var all_nums = 30;
	var correctness = 0; //前五关正确错误统计
	var ad_num = 3;//广告对应该值

	//下一组时，清除成功次数与底部金币图标
	function start_next(){
		var timing = setTimeout(function(){
				$('#score li').remove();
		},1000)
	}
	
	
	//金币飞入动画
	function goldFly(i){
		var offset = $('.left_box li').eq(i).offset();
		var gold_offset = $(".fot_gold").offset();
		var flyer = $('<img class="u-flyer" src="images/gold1.png">');
		flyer.fly({
			start: {
				left: gold_offset.left+200,
				top: gold_offset.top
			},
			end: {
				left: offset.left+50,
				top: offset.top+50,
				width: 0,
				height: 0
			},
			onEnd: function(){
				this.destory();
			}
		});		
	}
	
	
	//金币飞入钱袋的时间/添加金币
	function bag_time(i){
		setTimeout(function(){
			$('.left_box li').eq(i).css('background-image','url(images/stms/bag1.png)');	
		},500)
	}	
	
	
	//提示框显示
	function pop_show(ad_num){
		clearInterval(fn_timer);
		$(".popads").each(function() {
			$(this).hide()
			$(this).css('height',$(window).height())
		});
		
		if(ad_num>6){
			/*$('.popads').attr('id','ad1').show()
			$('.popads').find('img').attr('src','images/stms/1.gif')*/
			ad_num = 3;
			$('.popads').attr('id','ad'+ ad_num).show()
			$('.popads').find('img').attr('src',ROOT+'images/stms/'+ad_num+'.gif')
		}else{
			$('.popads').attr('id','ad'+ ad_num).show()
			$('.popads').find('img').attr('src',ROOT+'images/stms/'+ad_num+'.gif')
		}	
	}
	
	//提示框隐藏
	function pop_hide(){
		$('.popads').hide();	
	}
	
	//页面显示总关卡
	$('.game_level_all').html(game_level_all)
	$('.game_level_curr').html(game_level+1)
	
	
	
	
	
	pop_show(0)
	$('#ad0').find('.pro_ok').one("click",function(){
		pop_hide(0)
		$('#btn_star').show().addClass('animated bounceInDown')	
	})
	
	$("#btn_star .ok").one("click",function(){		
		console.log(timing_5s)
		start_init()
		
	});
	
	function start_init(){
		$('#btn_star').removeClass('bounceInDown').addClass('bounceOutUp').delay(1000).hide(0);		
		game_level = 0;
		$('.game_level_curr').text(game_level+1);
		function gameAreaCss(level){
				//设置下一关的game_area宽高值 
				
				var screenWidth = $(window).width();
					
				if(screenWidth<=375){
					gameMax_width = 300;
					console.log('screenWidth'+screenWidth)
							console.log('gameMax_width'+gameMax_width)	
				}else{
						gameMax_width = 340;
						console.log('screenWidth'+screenWidth)
						console.log('gameMax_width'+gameMax_width)			
				}			
					
						
				$('.game_area').css({
					'width':gameMax_width,
					'margin-left':-gameMax_width/2-10					
				})
			}	



		setTimeout(function(){
				if(music_on){
					musicPlay();
				}
				$(".con_wrap_1").fadeOut();
				$(".con_wrap_2").removeClass("wrap_prepare").addClass("game_area_show");
				gameArea=new GameArea();
				
				gameArea.currentLevel = 1;//修改初始关卡
				gameAreaCss(gameArea.currentLevel);
				var timer=setTimeout(function(){
					gameArea.initGame();//createGameItem(3,3,4);
				},300);
		},1000)
	}
	
	

	/************** penguin_item 点击开始 **************/
	
	$(".game_item_wrap").on("touchstart",".penguin_item",function(){
		console.log('发生点击事件============用户有操作');

		console.log('清除定时器1======'+fn_timer)
		clearInterval(fn_timer);
		if(gameArea.locked==1||$(this).hasClass("flip_out")){ //翻过了，或者动画还没解锁，则不做翻转操作
			return false;
		}
		
		$(this).addClass("flip_out");
		
		var select_item_num=$(this).data("index");
		
		for(var i=0;i<gameArea.array_penguin.length;i++){
			if((gameArea.array_penguin[i]+1)==select_item_num){
				post_currect++;
				gameArea.penguinFound();
								
				if(music_on){
					for(var j=0;j<4;j++){
						if (audio_click[j].paused) {
							audio_click[j].play(); 
							break;
						} else {
							continue;
						}
					}
				}
				
				break;
				
			}else{
				if(i==gameArea.array_penguin.length-1){ //如果含企鹅数组到最后一位，都没有能匹配点中选项的，则点中的选项是错误的
					post_false = 1;
					
					if(music_on){
						audio_click_wrong.play();
					}
					gameArea.showPenguinItem(true);//选错了，翻开正确的给用户看
					
					/*** 选错的情况，进入下一关 ***/					
					game_level++;
					console.log('当前关卡【game_level】：'+(game_level))
					console.log('总关卡【game_level_all】：'+game_level_all)
					correctArr.push(0);
					falseArr.push(0);
					var corrLen = correctArr.length;		
					if(correctArr[correctArr.length-1] != correctArr[correctArr.length-2]){
						trueArr.length = 0;	
					}	
					console.log('最后一次，选错时【currentLevel】:'+lastTrueLevel)
					console.log('当前级别【currentLevel】:'+gameArea.currentLevel)
					console.log('最后级别【totalLevel】:'+gameArea.totalLevel)
					console.log('***************翻转错误***************')
					console.log('翻转数组集合：' + correctArr)
					console.log('翻转错误数组：'+ falseArr)
					console.log('翻转正确数组：'+ trueArr)
					
					console.log('错误的个数：'+falseArr.length)
					
					
					if(falseArr.length % 3 == 0 && falseArr.length!=0){
						
						if(gameArea.currentLevel>1){
							gameArea.currentLevel=lastTrueLevel;
						}else{
							gameArea.currentLevel=1;
						}
							
					}else{
						gameArea.currentLevel	
					}
			 			
					
					var timer_showRightItem=setTimeout(function(){
						var timer=setTimeout(function(){
							gameArea.locked=0;
							
							//弹出个数减一个以后，翻转停止
							//点击“确定/关闭”，翻转开始
							
							if(game_level<game_level_all){
																
								if(game_level==5&&correctness<4){
									pop_show(2)		
									falseArr.length = 0;
								}else if(game_level==5&&correctness>=4){
									pop_show(1)	
									falseArr.length = 0;
								}else if(falseArr.length % 3 == 0 && falseArr.length!=0 && game_level>6){
									pop_show(2)	
								}else{
									gameArea.preLevel()
									$('.game_level_curr').html(game_level+1)		
								}	
								
							
								
								if($('.popads').is(':visible')){
									$('.pro_ok').unbind("click").click(function(){
										gameArea.timingTast();
										pop_hide();
										setTimeout(function(){
											gameArea.preLevel()
											$('.game_level_curr').html(game_level+1)	
										},300);
										
										if(game_level>6){
											ad_num++	
										}
									})	
								}
								
																							
							}else{
								gameArea.locked=1;
								$('.game_level_curr').html(game_level)	
								var accuracy = Math.round(success_count / game_level_all * 10000) / 100.00 + "%";								
								setTimeout(function(){
									$('.finish_pop').show().addClass('animated bounceInDown')
										if($('.finish_pop').is(':visible')){
											console.log('正确率'+accuracy)
											console.log('成功个数'+success_count)
											$('.finish_con').append('<span>正确率：'+accuracy+'</span><br><span>获得积分：'+success_count+'枚</span>')
											$('.finish_ok').unbind("click").click(function(){
												$('.finish_pop').removeClass('bounceInDown').addClass('bounceOutUp').delay(1000).hide(0);		
										})
									}		
											
								},1000)	
							}
						},1500);
					},1000);
				
				}
			}
		}
		console.log('post_currect=-======================'+post_currect)
		console.log('gameArea.array_penguin.length=-======================'+gameArea.array_penguin.length)
		if(post_currect == gameArea.array_penguin.length){
			console.log('****************判断正确*****************')
			respond_time=new Date().getTime()-start_respond_time
			respond_times.push(new Date().getTime()-start_respond_time)
			console.log('判断正确+++++++++++++++++++'+ respond_time);
			postData();
			post_currect = 0;
			post_false = 0;
		}
		if(post_false){
			console.log('****************判断错误*****************')
			respond_time=new Date().getTime()-start_respond_time
			respond_times.push(new Date().getTime()-start_respond_time)
			console.log('判断正确+++++++++++++++++++'+ respond_time);
			postData();
			post_currect = 0;
			post_false = 0;
		}
			
	});
	/************** penguin_item 点击结束 **************/	



	/********  控制关卡 *********/
	function GameArea(){
		this.array_matrix;
		this.array_penguin;
		this.time_penguin_num=0;
		this.elem=$(".game_area");
		this.num_total=0;
		this.num_found=0;
		this.currentLevel=1;//第一关开始值，对应array_mission数组值
		this.penguinNum;
		this.totalLevel=10; //总关卡10(连对3关升一级，总共30关)
		this.locked=0;
		this.roundinfo;
		this.gameFirstStart=1;
		
		this.initGame=function(){
			console.log('初始化游戏=====================开始');
			var level=this.currentLevel;
			this.createGameItem(array_mission[level-1].row,array_mission[level-1].col,array_mission[level-1].num);
			$(".game_area_show .star_area").css({
				"animation":"a_opacity 0.3s "+this.time_penguin_num+"s ease-in-out both"
			});
			this.timingTast();
			console.log('初始化游戏=====================结束');
		}
		
		
		
		this.createGameItem=function(num_i,num_j,num_total){
			this.initArray(num_i,num_j,num_total);
			var str="";
			var separate_margin=15; //每个item之间的间距
			var game_wrap_padding=0; //游戏区域内间距
			var game_wrap_width=gameMax_width //游戏区域宽度
			var item_width=Math.round(((game_wrap_width-game_wrap_padding*2)-separate_margin*(num_j-1))/num_j);
			//单个item的宽度
			var start_delay=0;
			if(this.gameFirstStart==1){
				this.gameFirstStart=0;
				$(".start_tips_wrap").addClass("start_tips_wrap_show");
				start_delay=0; //秒为单位
				var timer=setTimeout(function(){
					$(".start_tips_wrap").fadeOut();
					var timer_2=setTimeout(function(){
						$(".start_tips_wrap").remove();
					},100);
				},start_delay*100);
			}

			for(var i=0;i<num_i*num_j;i++){
				
				for(var j=0;j<this.array_penguin.length;j++){
					
					
					//计算不同数组组合的元素位置 模取个位，除取十位
					var x=11+(item_width+separate_margin)*(i%num_j);
					var y=11+(item_width+separate_margin)*Math.floor(i/num_j); 
					
					
					var time_delay=start_delay+Math.round((0.3+i%num_j/10+Math.floor(i/num_j)/10)*100)/100; //取小数点后一位	
					
					
					if(i==num_i*num_j-1){	
						this.time_penguin_num=time_delay+0.2;//再+0.2s黄点出来后缓节奏，再翻卡	
					}
				
					var scale_num=Math.ceil((item_width/104)*100)/100;
					
					if(i==this.array_penguin[j]){
						str+="<div class='penguin_item_hook' style='left:"+x+"px; top:"+y+"px; width:"+item_width+"px; height:"+item_width+"px; '><div class='penguin_item penguin_item_"+(i+1)+"' style=' width:"+item_width+"px; height:"+item_width+"px; -webkit-animation:a_game_item_show 0.3s "+time_delay+"s ease-in-out both;animation:a_game_item_show 0.3s "+time_delay+"s ease-in-out both;' data-index='"+(i+1)+"' data-flip='0'><div class='normal' style=' width:"+(item_width-4)+"px; height:"+(item_width-4)+"px;'></div><div class='front' style=' width:"+(item_width-4)+"px; height:"+(item_width-4)+"px;'></div></div></div>";	
						break;
					}else{
						if(j==this.array_penguin.length-1){
							str+="<div class='penguin_item_hook' style='left:"+x+"px; top:"+y+"px; width:"+item_width+"px; height:"+item_width+"px;'><div class='penguin_item penguin_item_"+(i+1)+"' style=' width:"+item_width+"px; height:"+item_width+"px; -webkit-animation:a_game_item_show 0.3s "+time_delay+"s ease-in-out both;animation:a_game_item_show 0.3s "+time_delay+"s ease-in-out both;' data-index='"+(i+1)+"' data-flip='0'><div class='normal' style=' width:"+(item_width-4)+"px; height:"+(item_width-4)+"px;'></div><div class='wrong' style=' width:"+(item_width-4)+"px; height:"+(item_width-4)+"px;'></div></div></div>";	
							
						}else{
							continue;
						}
					}
				}
			}
			this.locked=1; //生成元素，翻卡动画开始，加锁
			this.elem.children(".game_item_wrap").html(str);		
			this.showPenguinItem();
			console.log('***本次翻转个数***');
			console.log(this.array_penguin);
			$('.num_total').html('').append("["+this.array_penguin.length+"]")
		}
		
		
		
		

		
		
		
		this.initArray=function(num_i,num_j,num_total){
			this.num_found=0;
			this.num_total=num_total;
			this.array_matrix=[];
			for(var i=0;i<num_i;i++){
				this.array_matrix[i]=[];
				for(var j=0;j<num_j;j++){
					this.array_matrix[i][j]=0;
				}
			}
			
			
			var array_tem=[];
			for(var i=0;i<num_i*num_j;i++){
				array_tem[i]=i; //设置数组，抽取后删除，再从里面抽取，保证不会重复；
			}
			
			this.array_penguin=[];
			for(var i=0;i<num_total;i++){
				var num_ran=Math.floor(Math.random()*(num_i*num_j-this.array_penguin.length));
				this.array_matrix[Math.floor(array_tem[num_ran]/num_j)][array_tem[num_ran]%num_j]=1;
				this.array_penguin.push(array_tem[num_ran]);
				array_tem.splice(num_ran,1);
			}
	
			
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	
		
		this.showPenguinItem=function(keep){
			//如果keep为true 则保持翻开状态，默认翻开后再盖上
			this.locked=1; 
			var that=this;
			
			if(!keep){
				var timer=setTimeout(function(){
					//自动翻开企鹅位置
					for(var i=0;i<that.array_penguin.length;i++){
						$(".penguin_item_"+(that.array_penguin[i]+1)).addClass("flip_out");
					}
					var timer=setTimeout(function(){
						$(".flip_out").addClass("close_up");
						var timer2=setTimeout(function(){
							$(".flip_out").removeClass("flip_out").removeClass("close_up");
							$(".game_area_show .game_tips").show().addClass('animated rubberBand');
							
							that.locked=0; //翻卡动画结束，解锁
							start_respond_time = new Date().getTime();
							console.log('开始时间'+start_respond_time);
						},300);
					},flip_out_time); //900-300 静止600ms
				},this.time_penguin_num*1000);
				
			}else{
				var timer=setTimeout(function(){
					for(var i=0;i<that.array_penguin.length;i++){
						$(".penguin_item_"+(that.array_penguin[i]+1)).addClass("flip_out");
					}
				},1000);
			}
		}

		
		/*** 选对的情况，进入下一关 ***/
		this.nextLevel=function(){	
			
			
			console.log('当前级别【currentLevel】:'+this.currentLevel)
			console.log('最后级别【totalLevel】:'+this.totalLevel)
		
			correctArr.push(1);
			trueArr.push(1);
			success_count ++;	
			game_level++;
			correctness++;
			console.log('统计前五关的正确数：' + correctness)
			$('.game_score_curr').html(success_count)
			console.log('当前关卡【game_level】：'+(game_level))
			console.log('总关卡【game_level_all】：'+game_level_all)
			if(correctArr[correctArr.length-1] != correctArr[correctArr.length-2]){
				falseArr.length = 0;	
			}
			
			console.log('成功次数【success_count】：'+success_count)
	

			if(trueArr.length % 3 == 0 && trueArr.length!=0){
			
				if(this.currentLevel == this.totalLevel ){
					this.currentLevel=this.totalLevel;
				}else{
					lastTrueLevel = this.currentLevel
					this.currentLevel++;	
				}
				
			}else{
				this.currentLevel;
			}	
			
				
			console.log('****************翻转正确****************')
			console.log('翻转数组集合：' + correctArr)
			console.log('翻转错误数组：'+ falseArr)
			console.log('翻转正确数组：'+ trueArr)
				
				
			var that=this;
			var level=that.currentLevel;
			
			function gameAreaCss(level){
				//设置下一关的game_area宽高值 				
					var screenWidth = $(window).width();
					console.log('screenWidth:'+screenWidth)
					if(screenWidth<=375){
						gameMax_width = 300;
						console.log('screenWidth'+screenWidth)
						console.log('gameMax_width'+gameMax_width)	
					}else{
							gameMax_width = 340;
							console.log('screenWidth'+screenWidth)
							console.log('gameMax_width'+gameMax_width)		
					}
					$('.game_area').css({
						'width':gameMax_width,
						'margin-left':-gameMax_width/2-10				
					})
			}		
	
			
			//连续对三个时
			

			if(game_level==5&&correctness>=4){
				pop_show(1)	
				trueArr.length = 0;	
			}else if(game_level==5&&correctness<4){
				pop_show(2)	
				trueArr.length = 0;	
			}else if(game_level>6&&game_level%3==0){
				var falseAd = 0;//弹广告前，判断前三关是否弹出错误图片广告
				for(var ii = correctArr.length-4; ii< correctArr.length-1;ii++)
				 {
					  if(correctArr[ii]==0)
					  {
						falseAd++
					  }
				 }
				 console.log('falseAd:'+falseAd)
				if(falseAd>=3){
					setTimeout(function(){
						gameAreaCss(level)	
						that.createGameItem(array_mission[level-1].row,array_mission[level-1].col,array_mission[level-1].num);		
					},300);	
				}else{
					pop_show(ad_num)		
					console.log('弹出图片数：'+ ad_num)	
				}
				
			}else{
				gameAreaCss(level)
				that.createGameItem(array_mission[level-1].row,array_mission[level-1].col,array_mission[level-1].num);	
			}	
			
			if($('.popads').is(':visible')){
				$('.pro_ok').unbind("click").click(function(){
					that.timingTast();
					pop_hide();
					setTimeout(function(){
						gameAreaCss(level)	
						that.createGameItem(array_mission[level-1].row,array_mission[level-1].col,array_mission[level-1].num);		
					},300);
					
					if(game_level>6){
						ad_num++	
					}
				})
			}
		}
	
		this.preLevel=function(){
			var level=this.currentLevel;
			this.createGameItem(array_mission[level-1].row,array_mission[level-1].col,array_mission[level-1].num);
			this.timingTast();
		}
	
	
	
	
		//用户无操作时，当前题判断为错误，自动进入下一题
		this.timingTast = function(){
			clearInterval(fn_timer);
			fn_timer = setInterval(function(){

				post_false = 1;
				respond_time = new Date().getTime() - start_respond_time;
				respond_times.push(new Date().getTime()-start_respond_time)
				postData();
				post_false = 0;

				console.log('**********************定时器********************************');
					gameArea.showPenguinItem(true);//选错了，翻开正确的给用户看
					
					/*** 选错的情况，进入下一关 ***/					
						
						game_level++;
						console.log('当前关卡【game_level】：'+(game_level))
						console.log('总关卡【game_level_all】：'+game_level_all)
						correctArr.push(0);
						falseArr.push(0);
						var corrLen = correctArr.length;		
						if(correctArr[correctArr.length-1] != correctArr[correctArr.length-2]){
							trueArr.length = 0;	
						}	
						console.log('最后一次，选错时【lastTrueLevel】:'+lastTrueLevel)
						console.log('当前级别【currentLevel】:'+gameArea.currentLevel)
						console.log('最后级别【totalLevel】:'+gameArea.totalLevel)
						console.log('***************翻转错误***************')
						console.log('翻转数组集合：' + correctArr)
						console.log('翻转错误数组：'+ falseArr)
						console.log('翻转正确数组：'+ trueArr)
						
						console.log('错误的个数：'+falseArr.length)
						
						
						if(falseArr.length % 3 == 0 && falseArr.length!=0){
							
							if(gameArea.currentLevel>1){
								gameArea.currentLevel=lastTrueLevel;
							}else{
								gameArea.currentLevel=1;
							}	
						}else{
							gameArea.currentLevel	
						}
				
						
						var timer_showRightItem=setTimeout(function(){
							var timer=setTimeout(function(){
								gameArea.locked=0;
								
								//弹出个数减一个以后，翻转停止
								//点击“确定/关闭”，翻转开始
																
								if(game_level<game_level_all){
									gameArea.preLevel();
									$('.game_level_curr').html(game_level+1)	
								}else{
									gameArea.locked=1;
									$('.game_level_curr').html(game_level)	
									var accuracy = Math.round(success_count / game_level_all * 10000) / 100.00 + "%";								
									setTimeout(function(){
										$('.finish_pop').show().addClass('animated bounceInDown')
										if($('.finish_pop').is(':visible')){
											console.log('正确率'+accuracy)
											console.log('成功个数'+success_count)
											$('.finish_con').append('<span>正确率：'+accuracy+'</span><br><span>获得积分：'+success_count+'枚</span>')
											$('.finish_ok').unbind("click").click(function(){
												$('.finish_pop').removeClass('bounceInDown').addClass('bounceOutUp').delay(1000).hide(0);		
											})
										}		
									},1000)	
								}
								
								
							},1500);
						},1000);
						console.log('清除定时器========='+fn_timer);
					clearInterval(fn_timer);
				},flip_out_time+auto_next_time)//若无操作，自动进入下一级
				console.log('自动跳下一级时间：'+ (flip_out_time+auto_next_time))
				console.log('开启定时器========='+fn_timer);
	}
	

		
		this.penguinFound=function(){
			this.timingTast();
			this.num_found+=1;
			if(this.num_found==this.num_total){ //当找到的企鹅跟当前关卡企鹅总数一致时，当前关卡通关
				this.locked=1;
					if(game_level+1 < game_level_all){
						var that=this;
						var timer=setTimeout(function(){
							that.nextLevel();
							that.locked=0;
							$('.game_level_curr').html(game_level+1)		
						},1500)
						
					}else{	
						$('.game_level_curr').html(game_level)	
						var success_count_all = success_count+1 //加上最后一个成功
						var accuracy = Math.round(success_count_all / game_level_all * 10000) / 100.00 + "%";					
					
						$('.finish_pop').show().addClass('animated bounceInDown')
						if($('.finish_pop').is(':visible')){
							console.log('显示')
							$('.finish_con').append('<span>正确率：'+accuracy+'</span><br><span>获得积分：'+success_count_all+'枚</span>')
							$('.finish_ok').unbind("click").click(function(){
								$('.finish_pop').removeClass('bounceInDown').addClass('bounceOutUp').delay(1000).hide(0);	
							})
						}
									
					
					}	
			}
		}
		
	}
	/********  控制关卡 end*********/
	
	



	//关卡数据(几行几列几只动物)
	var array_mission=[{	//1
		"row":3,
		"col":3,
		"num":4,
		"perfect":20
	},{
		"row":3,			//2
		"col":3,
		"num":5,
		"perfect":40
	},{
		"row":4,			//3
		"col":4,
		"num":6,
		"perfect":70
	},{
		"row":4,			//4
		"col":4,
		"num":7,
		"perfect":110
	},{
		"row":5,			//5
		"col":5,
		"num":8,
		"perfect":160
	},{
		"row":5,			//6
		"col":5,
		"num":9,
		"perfect":220
	},{
		"row":5,			//7
		"col":5,
		"num":10,
		"perfect":290
	},{
		"row":6,			//8
		"col":6,
		"num":11,
		"perfect":370
	},{
		"row":6,			//9
		"col":6,
		"num":12,
		"perfect":460
	},{						//10
		"row":6,
		"col":6,
		"num":13,
		"perfect":560
	}];
	

	
	
	
	
	
	
	
	
	
	
	
	

			
	
	//页面加载完成，加载各声音文件
	$(window).load(function(){
		loadSound(); 
	})
	
	function pageStart(){
		
		$(".con_wrap_1").addClass("start_page_show");
		$(".ipengoo_shadow").remove();
	
	}
	
	var audio;
	var audio_click_wrong;
	var audio_game_over;
	var audio_click=[];
	
	function loadSound(){
		var loadfirst=true;
		var media_loaded=0;
		audio = document.createElement("audio");
		audio.src = ROOT+"mp3/bg.mp3";
		audio.load();
		audio.loop=true;
		
		
		var audio_click_1 = document.createElement("audio");
		audio_click_1.src = ROOT+"mp3/click.mp3";
		audio_click_1.load();
		
		var audio_click_2 = document.createElement("audio");
		audio_click_2.src = ROOT+"mp3/click.mp3";
		
		var audio_click_3 = document.createElement("audio");
		audio_click_3.src = ROOT+"mp3/click.mp3";
		
		var audio_click_4 = document.createElement("audio");
		audio_click_3.src = ROOT+"mp3/click.mp3";
		
		audio_click.push(audio_click_1);
		audio_click.push(audio_click_2);
		audio_click.push(audio_click_3);
		audio_click.push(audio_click_4);
		
		
		audio_click_wrong = document.createElement("audio");
		audio_click_wrong.src = ROOT+"mp3/click_wrong.mp3";
		audio_click_wrong.load();
		
		audio_game_over = document.createElement("audio");
		audio_game_over.src = ROOT+"mp3/game_over.mp3";
		audio_game_over.load();
		
		loadedTotal(); //ios 9 能通过canplaythrough ios10不能
		
		function loadedTotal(){
			media_loaded=4;
			//console.log(media_loaded);
			if(media_loaded>=4){
				if(loadfirst){
					var timer_loaded=new Date().getTime();
					var minus=timer_loaded-timer_enter;
					if(minus<3500){
						var timer=setTimeout(function(){
							pageStart();
						},3500-minus);
					}else{
						pageStart();
					}
					loadfirst=false;
				}
			}
		}	
	}
	
	function musicStop(){
		audio.pause();
		$(".music_ctrl .music_stop").hide();
		$(".music_ctrl .music_play").show();
	}
	
	function musicPlay(){
		audio.play();
	}

	function postData(){
		console.log(post_false)
		console.log('游戏id==============')
		console.log('当前关卡========'+game_level);
		console.log('是否正确=================='+(post_false == 1?'错误':'正确'))
		console.log('反应时间==================='+respond_time)
		console.log('获取金币数======================'+(post_false == 1?0:1))
		console.log('是否结束')
	}

	var timing_5s = 1;
	function auto_start(){
		timing_5s = setTimeout(function() {
			start_init();
		}, 5000);
	}
	// auto_start();
});
















